package com.yvtian.wm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yvtian.pu.pojo.PuApplyForEntity;
import com.yvtian.utils.StringHelper;
import com.yvtian.wm.pojo.WmStorehouseEntity;
import com.yvtian.wm.dao.WmStorehouseMapper;
import com.yvtian.wm.service.WmStorehouseService;
import org.springframework.stereotype.Service;

/**
 * (wm_storehouse)表服务实现类
 *
 * @author long
 * @since 2024-06-27 08:50:48
 */
@Service("wmStorehouseService")
public class WmStorehouseServiceImpl extends ServiceImpl<WmStorehouseMapper, WmStorehouseEntity> implements WmStorehouseService {

    @Override
    public IPage<WmStorehouseEntity> findByPage(Page<WmStorehouseEntity> page, WmStorehouseEntity wmStorehouseEntity) {
        LambdaQueryWrapper<WmStorehouseEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WmStorehouseEntity::getIsDel, 0);
        getQueryWrapper(wmStorehouseEntity, queryWrapper);
        return this.page(page, queryWrapper);
    }

    private void getQueryWrapper(WmStorehouseEntity wmStorehouseEntity, LambdaQueryWrapper<WmStorehouseEntity> queryWrapper) {
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getCode())){
            queryWrapper.like(WmStorehouseEntity::getCode, wmStorehouseEntity.getCode());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getName())){
            queryWrapper.like(WmStorehouseEntity::getName, wmStorehouseEntity.getName());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getAddress())){
            queryWrapper.like(WmStorehouseEntity::getAddress, wmStorehouseEntity.getAddress());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getLeaderName())){
            queryWrapper.like(WmStorehouseEntity::getLeaderName, wmStorehouseEntity.getLeaderName());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getLeaderUser())){
            queryWrapper.like(WmStorehouseEntity::getLeaderUser, wmStorehouseEntity.getLeaderUser());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getCreateName())) {
            queryWrapper.like(WmStorehouseEntity::getCreateName, wmStorehouseEntity.getCreateName());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getUpdateName())) {
            queryWrapper.like(WmStorehouseEntity::getUpdateName, wmStorehouseEntity.getUpdateName());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getCreateUser())) {
            queryWrapper.like(WmStorehouseEntity::getCreateUser, wmStorehouseEntity.getCreateUser());
        }
        if (StringHelper.isNotEmpty(wmStorehouseEntity.getRemarks())) {
            queryWrapper.like(WmStorehouseEntity::getRemarks, wmStorehouseEntity.getRemarks());
        }
    }
}

